<?php 
 include_once dirname(__FILE__)."/config.php";
 class universite_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_id;
		 protected $_intitulefr;
		 protected $_abuniv;
		 public function get_name_table(){ return "universite";}
		 public function get_name_id(){ return "id";}
		 public function get_name_intitulefr(){ return "intitulefr";}
		 public function get_name_abuniv(){ return "abuniv";}
		 public function set_id($parametre){  $this->_id=$parametre;}	
		 public function set_intitulefr($parametre){  $this->_intitulefr=$parametre;}	
		 public function set_abuniv($parametre){  $this->_abuniv=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id(){ return $this->_id;}
		 public function get_intitulefr(){ return $this->_intitulefr;}
		 public function get_abuniv(){ return $this->_abuniv;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 universite(
			intitulefr,
			abuniv)
 VALUES(
			'".$this->_intitulefr."',
			'".$this->_abuniv."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_intitulefr)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
intitulefr='".$this->_intitulefr."'";
}
if(!empty($this->_abuniv)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
abuniv='".$this->_abuniv."'";
}
$sql="UPDATE 
universite SET 
 ".$sql."
								WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
universite 
 
									WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
universite ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id,
		intitulefr,
		abuniv
 FROM 
 universite";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_id=$row->id;
		$this->_intitulefr=$row->intitulefr;
		$this->_abuniv=$row->abuniv;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>